package 笔试题;

import java.util.ArrayList;

/**
 * @author 帅小伙
 * @date 2022/1/8
 * @description
 * https://leetcode-cn.com/contest/weekly-contest-274/problems/number-of-laser-beams-in-a-bank/
 */
public class Demo2125银行中的激光束数量 {


    public int numberOfBeams(String[] bank) {

        ArrayList<Integer> integers = new ArrayList<>();
        for (int i = 0; i < bank.length; i++) {
            int count = 0;
            for (char c: bank[i].toCharArray()) {
                if(c=='1'){
                    count++;
                }
            }
            if(count!=0){
                integers.add(count);
            }



        }

        int res=0;
        for (int i = 1; i < integers.size(); i++) {
            res+=integers.get(i-1)*integers.get(i);
        }
        return res;

    }

}
